package com.zyg.user.controller;

import com.zyg.common.utils.PhoneFormatCheckUtils;
import com.zyg.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * ------------------------------
 * 作者: LMY
 * 类-功能: XX
 * 创建时间: 2021-11-09 10:17
 * ------------------------------
 **/
@Controller
@RequestMapping
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping({"register.html"})
    public String register(){
        return "register";
    }

    @GetMapping("/getCode")
    public String getCode(String phone){
        //1. 判断是否合法
        if(PhoneFormatCheckUtils.isPhoneLegal(phone)){
            userService.sendCode(phone);
        }
        //2. 跳转回页面
        return "register";
    }

    @GetMapping("/")
    public String index(){
        return "home-index";
    }


}
